package cn.xuchunh.tiq.storage.sp;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by XuChunH on 2015/8/31.
 */
public class SharedPreferenceManager {

    private static final String NAME = "info";

    public static final String IDCARD = "idcard";
    public static final String PHONE = "phone";

    private static SharedPreferenceManager instance;
    private SharedPreferences sharedPreferences;
    private SharedPreferences.Editor editor;

    public synchronized static SharedPreferenceManager getInstance(Context context) {
        if (instance == null) {
            instance = new SharedPreferenceManager(context.getApplicationContext());
        }
        return instance;
    }

    private SharedPreferenceManager(Context context) {
        sharedPreferences = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
        editor = sharedPreferences.edit();
    }

    public String getIDCard() {
        return sharedPreferences.getString(IDCARD, "");
    }

    public void setIDCard(String idCard) {
        editor.putString(IDCARD, idCard);
        editor.commit();
    }

    public String getPhone() {
        return sharedPreferences.getString(PHONE, "");
    }

    public void setPhone(String phone) {
        editor.putString(PHONE, phone);
        editor.commit();
    }

}
